package com.bjfu.demo.controller;

import com.bjfu.demo.dao.DataMapper;
import com.bjfu.demo.dao.SiteDataMapper;
import com.bjfu.demo.entity.Data;
import com.bjfu.demo.entity.SiteData;
import com.bjfu.demo.entity.SiteDataExample;
import com.bjfu.demo.entity.SiteDataExample.Criteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created on 2021-04-29
 */
@RestController
public class TestController {

    @Autowired
    private SiteDataMapper siteDataMapper;

    @Autowired
    private DataMapper dataMapper;


    @GetMapping("/test")
    public Object test(){

        SiteDataExample siteDataExample = new SiteDataExample();
        Criteria criteria = siteDataExample.createCriteria();
        //添加city条件
        criteria.andDistrictEqualTo("杭州");
        List<SiteData> siteData = siteDataMapper.selectByExample(siteDataExample);
        return null;
    }
    @GetMapping("/data/{id}")
    public Object tes2(@PathVariable Integer id){
        Data data = dataMapper.selectByPrimaryKey(id);
        return data;
    }
}
